<template>
	<view class="alarm-icon-container" @click="handleClick">
		<!-- 闹钟图标 -->
		<image :src="alarm.onLineState === 1 ? '/static/images/clock_selected.png' : '/static/images/clock.png'"
			class="alarm-icon"></image>
		<!-- 删除按钮 -->
		<text class="delete-btn" @click.stop="onDelete">×</text>
		<!-- 闹钟名称 -->
		<text class="alarm-name">{{ alarm.clockName }}</text>
		<!-- 在线状态 -->
		<text :class="['status-text', alarm.onLineState === 1 ? 'status-online' : 'status-offline']">
			{{ alarm.onLineState === 1 ? '在线' : '离线' }}
		</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		props: {
			alarm: {
				type: Object,
				required: true
			}
		},
		methods: {
			onDelete() {
				this.$emit('delete', this.alarm)
			},
			handleClick() {
				this.$emit('click', this.alarm)
			}
		}
	}
</script>

<style>
	.alarm-icon-container {
		position: relative;
		background-color: #f9f9f9;
		border-radius: 8px;
		padding: 10px;
		text-align: center;
		height: 150px;
		display: flex;
		flex-direction: column;
		justify-content: center;
		cursor: pointer;
	}

	.alarm-icon {
		width: 60px;
		height: 60px;
		object-fit: contain;
		margin: 0 auto;
	}

	.delete-btn {
		position: absolute;
		top: 5px;
		right: 5px;
		color: #f56c6c;
		font-size: 18px;
		font-weight: bold;
	}

	.alarm-name {
		margin-top: 10px;
		font-size: 14px;
		font-weight: 500;
	}

	.status-text {
		position: absolute;
		bottom: 5px;
		right: 10px;
		font-size: 12px;
	}

	.status-online {
		color: #07C160;
		/* 红色 */
	}

	.status-offline {
		color: #999;
		/* 灰色 */
	}
</style>